package impl

import (
	"context"
	"git.mycaigou.com/gfyx/micro-gfyx-bigdata-service/infrastructure/repository/bigdata/contract"
	"git.mycaigou.com/gfyx/micro-gfyx-bigdata-service/infrastructure/repository/model/bigdata"
	"git.myscrm.cn/golang/stark/v4"
	"gorm.io/gorm"
)

type ApiParamRepo struct {
}

func NewApiParamRepo() contract.ApiParamRepoIface {
	return &ApiParamRepo{}
}

func (a *ApiParamRepo) GetApiParamList(ctx context.Context, apiId int32, category string) ([]*bigdata.ApiParam, error) {
	db := stark.MySQLConn.Get(ctx)
	apiParams := make([]*bigdata.ApiParam, 0)
	db = db.Where("api_id = ? and category = ?", apiId, category).Find(&apiParams)
	if db.Error != nil && db.Error != gorm.ErrRecordNotFound {
		return nil, db.Error
	}
	return apiParams, nil
}
